String Functions of Rule Engine |
|
String functions can be used to manipulate string values. You can convert strings to integers, return length of the strings, extract substrings, and remove leading and trailing spaces.
The following table describes the various string functions available in the rule engine function library and their usage.
Table 1. Rule Engine String Functions
String Functions |
Description |
Usage |
---|---|---|
number(e) |
Converts a string expression into an integer. |
number(e), where |
string (e) |
Converts a numeric expression into a string. |
string(e), where |
string-length (e1) |
Returns the number of characters in a given string. |
string-length (e1), where |
normalize-space(' e1 ') |
Removes the trailing spaces from the input string expression. |
normalize-space(' e1 '), where |
concat(e1,e2) |
Concatenates the given string parameters. |
concat(e1,e2), where e1 and e2 are string expressions which you want to join. |
starts-with(e1, e2) |
Returns true if the first argument string starts with the second argument string, and otherwise returns false |
starts-with(e1, e2), where e1 and e2 are strings, and returns true if the string e1 starts with the string e2.For example: starts-with('Arnold', 'A')The result of the above function istrue. |
contains(e1, e2) |
Returns true if the first argument string contains the second argument string, and otherwise returns false |
contains(e1, e2), where e1 and e2 are strings, and returns true if the string e1 contains the string e2.For example: contains('Arnold', 'n')The result of the above function istrue. |
substring-before(e1, e2) |
Returns the start of string1 before string2 occurs in it |
substring-before(e1, e2), where e1 and e2 are strings.For example: substring-before('Arnold', 'o')The result of the above function is 'Arn' |
substring-after(e1, e2) |
Returns the remainder of string1 after string2 occurs in it |
substring-after(e1, e2), where e1 and e2 are strings.For example: substring-after('Arnold', 'n')The result of the above function is 'old' |
substring(e1,x,y) |
Returns the substring from the start position to the specified length. Index of the first character is
1. If length is omitted it returns the substring from the start position to the end
|
substring(e1,x,y), where e1 is the string, x is an integer which indicates the start position, y is an integer which indicates the length.For example: substring('Arnold', 2,3)The result of the above function is 'rno' |
pos(e1,e2) |
Returns the starting position (first index) of a specified string within the source string. |
pos(e1,e2), where:
|
rpos(e1,e2) |
Calculates the starting position of a specified string from its rightmost occurrence within the source string. |
rpos(e1,e2), where:
|
asc(e1) |
Returns the ASCII code for a specified character. |
asc(e1), where |
chr(e1) |
Returns the character represented by the given integer value. |
chr(e1), where |